<?php   // $Id: devis_modif_article.php 280 2008-08-15 16:53:15Z pcoustillas $ ?>
<?php  
/*Copyright (C) 2003-2004 Guy Hendrickx
Licensed under the terms of the GNU  General Public License:http://www.opensource.org/licenses/gpl-license.php
File Authors:Guy Hendrickx */
require_once("include/verif.php");
require_once("include/config/common.php");

$quanti=isset($_POST['quantite'])?$_POST['quantite']:"";
$num_cont=isset($_POST['num_cont'])?$_POST['num_cont']:"";
$dev_num=isset($_POST['num_devis'])?$_POST['num_devis']:"";
$article=isset($_POST['article'])?$_POST['article']:"";

$sql = "SELECT prix_htva, taux_tva FROM ${tblpref}article WHERE ${tblpref}article.num = $article";
$req = mysql_query($sql) or die("Erreur selection article <br/>$sql<br/>".mysql_error());

$data = mysql_fetch_array($req);

$prix_article = $data['prix_htva'];
$taux_tva = $data['taux_tva'];


$tot_htva = $quanti * $prix_article ;
$tot_tva = $tot_htva / 100 * $taux_tva ;


$sql2 = "UPDATE ${tblpref}cont_dev SET  quanti='$quanti', article_num='$article', 
		tot_art_htva='$tot_htva', to_tva_art='$tot_tva'  WHERE num = '$num_cont'";

mysql_query($sql2) or die("Erreur mise à jour de l'article<br/>$sql2<br/>".mysql_error());

header("Location: devis_edit.php?num_devis=$dev_num");
?> 
